package test5;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Indexed;

import java.util.Arrays;

/**
 * @author: mornd
 * @dateTime: 2023/5/11 - 21:00
 *                  @Indexed 注解的使用，加快 spring 检索组件速度
 */
public class App {

    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanFactory);

        scanner.scan(App.class.getPackage().getName());

        Arrays.stream(beanFactory.getBeanDefinitionNames()).forEach(System.out::println);
    }

    //@Indexed
    @Component // @Component 注解已经包含 @Indexed
    static class Bean1 {}
    @Component
    static class Bean2 {}
}
